package com.zlkj.pro.modular.app.controller;

import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import com.zlkj.pro.core.util.JsonUtils;
import com.zlkj.pro.modular.admin.entity.Config;
import com.zlkj.pro.modular.business.model.dto.ReportDTO;
import com.zlkj.pro.modular.business.model.vo.ReportFlowVO;
import com.zlkj.pro.modular.business.model.vo.ReportVO;
import com.zlkj.pro.modular.business.service.ReportService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

import static com.zlkj.pro.core.consts.ProjectConstants.SERVICE_APP_PREFIX;

/**
 * @author liyang
 * @date 2024/4/6
 * @time 14:34
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@ApiResource(name = "产品信息", path = SERVICE_APP_PREFIX + "/report")
public class AppReportController {

    private final ReportService reportService;

    @GetResource(name = "报备单列表", path = "/findList")
    public ResponseData findList(ReportDTO dto) {
        List<ReportVO> restData = reportService.findList(dto);
        return new SuccessResponseData(restData);
    }

    @GetResource(name = "报备单列表", path = "/countReports")
    public ResponseData countReports(ReportDTO dto) {
        Map<String,Object> restData = reportService.countReports(dto);
        return new SuccessResponseData(restData);
    }

    @GetResource(name = "报备单系统配置", path = "/findConfig")
    public ResponseData findConfig() {
        List<Config> restData = reportService.findConfig();
        return new SuccessResponseData(restData);
    }


    @PostResource(name = "添加", path = "/add")
    public ResponseData add(@RequestBody ReportDTO dto) {
        boolean restData = reportService.add(dto);
        return new SuccessResponseData(restData);
    }

    @PostResource(name = "成交确认", path = "/confirm")
    public ResponseData confirm(@RequestBody ReportDTO dto) {
        boolean restData = reportService.confirm(dto);
        return new SuccessResponseData(restData);
    }

    @GetResource(name = "客户不认可原因", path = "/getNotApproveReason")
    public ResponseData getNotApproveReason() {
        List<String> restData = reportService.getNotApproveReason();
        return new SuccessResponseData(restData);
    }


    @PostResource(name = "申请延期", path = "/delay")
    public ResponseData delay(@RequestBody ReportDTO dto) {
        boolean restData = reportService.delay(dto);
        return new SuccessResponseData(restData);
    }


    @GetResource(name = "报备单详情", path = "/findDetail")
    public ResponseData findDetail(Long id, Long userId) {
        ReportVO restData = reportService.findDetail(id,userId);
        return new SuccessResponseData(restData);
    }

    @GetResource(name = "报备单流程列表", path = "/getFlow")
    public ResponseData getFlow(Long id) {
        List<ReportFlowVO> restData = reportService.getFlow(id);
        return new SuccessResponseData(restData);
    }


}
